<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
	/**
	 * CodeIgniter
	 *
	 * An open source application development framework for PHP 4.3.2 or newer
	 *
	 * @package		CodeIgniter
	 * @author		ExpressionEngine Dev Team
	 * @copyright	Copyright (c) 2008 - 2009, EllisLab, Inc.
	 * @license		http://codeigniter.com/user_guide/license.html
	 * @link		http://codeigniter.com
	 * @since		Version 1.0
	 * @filesource
	 */
	// ------------------------------------------------------------------------
	
	/**
	 * @package		CodeIgniter
	 * @subpackage	Libraries
	 * @author		AnhDT
	 */
	require_once APP_LIBRARY_PATH . 'tree/paginator/scrolling/st_paginator_scrolling_interface.php';
	class st_paginator_scrolling_slider implements st_paginator_scrolling_interface {
		public function getPages(st_paginator $_paginator, $_pageRange = null) {
			if ($_pageRange === null) {
				$_pageRange = $_paginator->getPageRange();
			}
			$pageNumber = $_paginator->getCurrentPageNumber();
			$pageCount  = count($_paginator);
			if ($_pageRange > $pageCount) {
				$_pageRange = $pageCount;
			}
			$delta = ceil($_pageRange / 2);
			if ($pageNumber - $delta > $pageCount - $_pageRange) {
				$lowerBound = $pageCount - $_pageRange + 1;
				$upperBound = $pageCount; 
			} else {				
				if ($pageNumber - $delta < 0) {
					$delta = $pageNumber;
				}
				$offset     = $pageNumber - $delta;
				$lowerBound = $offset + 1; 
				$upperBound = $offset + $_pageRange;
			}	
			return $_paginator->getPagesInRange($lowerBound, $upperBound);
		}	
	}
?>